﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import reprise.tweens.*;
    import net.wooga.pets.constants.*;
    import net.wooga.pets.utils.*;
    import com.robertpenner.easing.*;

    public class TruckView extends RenderListView {

        private var _truck:MovieClip;
        private var _sign:MovieClip;
        private var _speechBubbleContainer:Sprite;

        private static const TRUCK_DOCK_POS:Point = new Point(6100, 1980);
        private static const SEND_AWAY_POS:Point = new Point(10000, 1980);
        private static const SEND_AWAY_SPEED:int = 3000;
        private static const COME_BACK_POS:Point = new Point(4000, 1980);
        private static const COME_BACK_SPEED:int = 3000;
        private static const SIGN_POS:Point = new Point(5900, 1850);
        private static const SPEECHBUBBLE_POS:Point = new Point(6200, 2000);

        public function TruckView():void{
        }
        public function init():void{
            buttonMode = true;
            this._sign = AssetsLibrary.getMovieClip("Goods_Sign");
            this._sign.x = SIGN_POS.x;
            this._sign.y = SIGN_POS.y;
            addChild(this._sign);
            this._truck = AssetsLibrary.getMovieClip("Goods_Truck");
            this._truck.visible = false;
            addChild(this._truck);
            this._speechBubbleContainer = new Sprite();
            this._speechBubbleContainer.visible = false;
            this._speechBubbleContainer.x = SPEECHBUBBLE_POS.x;
            this._speechBubbleContainer.y = SPEECHBUBBLE_POS.y;
            this._speechBubbleContainer.mouseEnabled = false;
            this._speechBubbleContainer.mouseChildren = false;
            addChild(this._speechBubbleContainer);
            visible = false;
        }
        public function parkTruckDesideHospital(_arg1:Boolean=true):void{
            this._truck.visible = true;
            this._truck.x = TRUCK_DOCK_POS.x;
            this._truck.y = TRUCK_DOCK_POS.y;
            var _local2:String = (_arg1) ? "still" : "still_full";
            this._truck.gotoAndStop(_local2);
        }
        public function sendTruckAway():void{
            this._truck.visible = true;
            this._truck.gotoAndStop("go_away");
            var _local1:SimpleTween = new SimpleTween(SEND_AWAY_SPEED);
            _local1.addTweenProperty(this._truck, "x", this._truck.x, SEND_AWAY_POS.x, Quad.easeInOut);
            _local1.addEventListener(Event.COMPLETE, this.onSendAwayComplete);
            _local1.execute();
        }
        public function deliverGoods():void{
            this._truck.visible = true;
            this._truck.y = COME_BACK_POS.y;
            this._truck.gotoAndStop("come_back");
            var _local1:SimpleTween = new SimpleTween(COME_BACK_SPEED);
            _local1.addTweenProperty(this._truck, "x", COME_BACK_POS.x, TRUCK_DOCK_POS.x, Quad.easeInOut);
            _local1.addEventListener(Event.COMPLETE, this.onDeliveryComplete);
            _local1.execute();
        }
        private function onSendAwayComplete(_arg1:Event):void{
            this._truck.visible = false;
            this._truck.x = COME_BACK_POS.x;
            this._truck.y = COME_BACK_POS.y;
        }
        private function onDeliveryComplete(_arg1:Event):void{
            dispatchEvent(new Event(EventConstants.TRUCK_ARRIVED));
        }
        public function get truck():MovieClip{
            return (this._truck);
        }
        public function get sign():MovieClip{
            return (this._sign);
        }
        public function get speechBubbleContainer():Sprite{
            return (this._speechBubbleContainer);
        }

    }
}//package net.wooga.pets.views.components 
